#ifndef _TIME_COUNT_
#define _TIME_COUNT_
#include <boost/timer/timer.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <string>
#include <fstream>
using std::string;

class Time_Count{
  boost::posix_time::ptime time_now,time_now1;
  boost::posix_time::millisec_posix_time_system_config::time_duration_type time_elapse;
 public:
  void start(){
    time_now = boost::posix_time::microsec_clock::universal_time();
  };

  double sec(){
    time_now1 = boost::posix_time::microsec_clock::universal_time();

    time_elapse = time_now1 - time_now;

    return time_elapse.ticks()/1000000.0;
  };

  double min(){
    time_now1 = boost::posix_time::microsec_clock::universal_time();

    time_elapse = time_now1 - time_now;

    return time_elapse.ticks()/1000000.0/60.0;
  };

  double hour(){
    time_now1 = boost::posix_time::microsec_clock::universal_time();

    time_elapse = time_now1 - time_now;

    return time_elapse.ticks()/1000000.0/60.0/60.0;
  };

  void end(){
    time_now1 = boost::posix_time::microsec_clock::universal_time();

    time_elapse = time_now1 - time_now;

    double sec = time_elapse.ticks()/1000000.0;
    std::cout<<" Time cost : "<<sec<<"s"<<std::endl;
  };

  void print_time(){
    std::string strTime = boost::posix_time::to_iso_string(
        boost::posix_time::second_clock::local_time());
    int pos = strTime.find('T');
    strTime.replace(pos, 1, std::string("-"));
    strTime.replace(pos + 3, 0, std::string(":"));
    strTime.replace(pos + 6, 0, std::string(":"));
    //return strTime;
    std::cout << "            Date&Time : " << strTime.c_str() << std::endl;
  }

  void print_time(std::ofstream & file){
    std::string strTime = boost::posix_time::to_iso_string(
        boost::posix_time::second_clock::local_time());
    int pos = strTime.find('T');
    strTime.replace(pos, 1, std::string("-"));
    strTime.replace(pos + 3, 0, std::string(":"));
    strTime.replace(pos + 6, 0, std::string(":"));
    //return strTime;
    file << "            Date&Time : " << strTime.c_str() << std::endl;
  }

};



#endif
